#include "send_packet_pool.h"



send_packet_pool& send_packet_pool::instance()
{
	static send_packet_pool inst;
	return inst;
}

send_packet_pool::stream_ptr send_packet_pool::pop()
{
	lock_section(ct_);

	if(pool_.size() > 0)
	{
		auto stream = pool_[pool_.size()-1];
			
		pool_.pop_back();

		stream->clear();

		return stream;
	}

	send_packet_stream::ptr send_packet_ptr( new send_packet_stream );

	return send_packet_ptr;
}

void send_packet_pool::push( stream_ptr packet )
{
	if(packet == nullptr)
		return;

	lock_section(ct_);

	pool_.push_back(packet);
}
